package com.gemcoder.system.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Map;
import javax.annotation.Resource;
import com.gemcoder.system.bo.Result;
import com.gemcoder.system.service.RolemanagementService;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;

@Controller
@RequestMapping("/Rolemanagement")
public class RolemanagementController {

    @Resource
    private RolemanagementService RolemanagementService;

    @RequestMapping(value = "/getRolesByRoleName")
    @ResponseBody
    public Result getRolesByRoleName(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.getRolesByRoleName(paramMap);
    }

    @RequestMapping(value = "/getAllRoles")
    @ResponseBody
    public Result getAllRoles(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.getAllRoles(paramMap);
    }

    @RequestMapping(value = "/getRolesByPage")
    @ResponseBody
    public Result getRolesByPage(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.getRolesByPage(paramMap);
    }

    @RequestMapping(value = "/showEditModal")
    @ResponseBody
    public Result showEditModal(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.showEditModal(paramMap);
    }

    @RequestMapping(value = "/deleteRole")
    @ResponseBody
    public Result deleteRole(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.deleteRole(paramMap);
    }

    @RequestMapping(value = "/updateRolePermissions")
    @ResponseBody
    public Result updateRolePermissions(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.updateRolePermissions(paramMap);
    }

    @RequestMapping(value = "/addRole")
    @ResponseBody
    public Result addRole(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 校验 RoleName1value1 是否为空
        if (paramMap.get("RoleName1value1") == null || String.valueOf(paramMap.get("RoleName1value1")).trim().isEmpty()) {
            return new Result(false, "RoleName1value1不能为空!", null);
        }
        // 校验 RoleCodevalue1 是否为空
        if (paramMap.get("RoleCodevalue1") == null || String.valueOf(paramMap.get("RoleCodevalue1")).trim().isEmpty()) {
            return new Result(false, "RoleCodevalue1不能为空!", null);
        }
        //调用service层的代码
        return RolemanagementService.addRole(paramMap);
    }

    @RequestMapping(value = "/getAllRoles0VT")
    @ResponseBody
    public Result getAllRoles0VT(@RequestBody(required = false) Map<String, Object> paramMap) {
        // 没有需要校验的入参
        //调用service层的代码
        return RolemanagementService.getAllRoles0VT(paramMap);
    }

    @RequestMapping(value = "/getAllPermissions")
    @ResponseBody
    public Result getAllPermissions(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.getAllPermissions(paramMap);
    }

    @RequestMapping(value = "/getRolePermissions")
    @ResponseBody
    public Result getRolePermissions(@RequestBody(required = false) Map<String, Object> paramMap) {
        //如果有需要校验的入参, 请在这里补充代码进行校验
        //调用service层的代码
        return RolemanagementService.getRolePermissions(paramMap);
    }
}
